const app = getApp()
const request = require('../../utils/promise.js');
const common = require('../../utils/common.js');

Page({
  data: {
    StatusBar: app.globalData.StatusBar,
    CustomBar: app.globalData.CustomBar,
    WebUrl: app.globalData.weburl,
    contentDetail: null,
    contentId: null,
    userInfo: [],
  },
  onLoad: function (option) {
    console.log('parmindex', option.id);
    this.setData({
      contentId: option.id
    });
    this.loadLession(option.id);
    var openid = wx.getStorageSync('openid');
    if (openid != "") {
      this.getUserInfo(openid);
    }
  },
  loadLession: function (val) {
    var parm = {
      "contentId": val,
    };
    request.GET("/mdz/content/contentdetail", parm).then(res => {
      console.log('contentdetail', res.data);
      if (res.data.code == "200") {
        this.setData({
          contentDetail: res.data.data
        });
      }
      else {
        common.CheckErrorForBusiness(res.data.message);
      }
    })
  },
  getUserInfo: function (openid) {
    var parm = {
      "openid": openid,
    };

    request.GET("/mdz/reguser/getuserinfo", parm).then(res => {
      console.log(res);
      if (res.data.code == "200") {
        this.setData({
          userInfo: res.data.data,
        });
      }
      else {
        common.CheckErrorForBusiness(res.data.msg);
      }
    })
  },
})
